﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UtilityLibrary.Ormapping;
using WZ.Entity;

namespace WZ.Stock.Data
{
    public class dic_CompanyClassDAL : AttributeAdapterBase<dic_CompanyClass>
    {
        static WZ.DC.Config.DBConfig<dic_CompanyClass> dbConfig = new WZ.DC.Config.DBConfig<dic_CompanyClass>();
        public dic_CompanyClassDAL()
            : base(dbConfig.DBConnStr)
        {
        }
        public bool insertCommpanyClass(string companyCode, string classTypeName, int classId)
        {

            string sql = @"INSERT INTO [dbo].[Commpany_Class]
           ([ClassId]
           ,[CompanyCode]
           ,[ClassTypeName])
     VALUES
           (@classId
           ,@companyCode
           ,@classTypeName)
";
            return RunSql(sql
                   , new SqlParameter("@classId", classId)
                   , new SqlParameter("@companyCode", companyCode)
                   , new SqlParameter("@classTypeName", classTypeName)) > 0;
        }
        public List<dic_CompanyClass> GetClassByCompanyCode(string companyCode)
        {
            return SelectTo("SELECT * FROM Dic_CompanyClass WHERE ID in(SELECT ClassId FROM Commpany_Class WHERE CompanyCode=@companyCode)", new SqlParameter("@companyCode", companyCode)).ToList();
        }
    }
}
